#encoding:utf8

import sys, os, time
import xlrd

if __name__=='__main__':
    if len(sys.argv)==1:
        print('Please input the .xls log file for read')
    else:
#        logdir=u'D:\\me\\perfectworld\\工作日志'
#        logname= destname= time.strftime(u'%Y-%m-%d', time.localtime())+u'李现民.xls'
#        logpath= os.path.join(logdir, logname)
        logpath= sys.argv[1]
        if not os.path.exists(logpath):
            print('The input log file path', logpath, 'does not exists')
            sys.exit(1)
        
        book = xlrd.open_workbook(logpath)
        sheet = book.sheet_by_index(0)
        text_file_path= '%s.log'%__file__
        
        with open(text_file_path, 'w') as fout:
            num_rows= sheet.nrows
            index= 1
            
            for row_index in range(4, num_rows):
                text= sheet.cell_value(rowx=row_index, colx=1)
                if len(text):
                    text= text.encode('gbk')
                    fout.write('%d: %s \n'%(index, text))
                    index+= 1
        
        os.system('start %s'%text_file_path)
        
